home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / qwik30.arc / QINIT.INC < prev    next >
Text File  |  1991-01-09  |  10KB  |  157 lines

  1. { Qinit.inc - initialization for QWIK screen procedures     ver 3.0, 08-31-87 }
  2. { This initialization routine checks for the type of video card and sets the
  3.   parameters for the procedures: addresses, wait-for-retrace, and number of
  4.   pages including system codes that can be used for testing in your program.  }
  5.  
  6. type
  7.   Str80   = string[80];                { Type for Qwrites.inc }
  8.  
  9. var
  10.   Vmode:       byte    absolute $0040:$0049; { Video mode: Mono=7, Color=0-3 }
  11.   EgaRows:     byte    absolute $0040:$0084; { Rows on screen (0-based) }
  12.   EgaFontSize: integer absolute $0040:$0085; { Character cell height (1-based)}
  13.   EgaInfo:     byte    absolute $0040:$0087; { EGA info.  See QINIT.DOC }
  14.   CRTcolumns:  byte    absolute $0040:$004A; { Number of CRT columns (1-based)}
  15.   Page0seg,                   { Segment for page 0 }
  16.   Qseg:        integer;       { Segment for Q writing }
  17.   MaxPage:     byte;          { Maximum possible page }
  18.   CardWait,                   { Wait-for-retrace for video card }
  19.   Qwait,                      { Wait-for-retrace while Q writing }
  20.   HavePS2:     boolean;       { Using some type of IBM PS/2 equip }
  21.   EgaSwitches,                { EGA card and monitor setup }
  22.   SystemID,SubModelID,        { Equipment ID. See QINIT.DOC }
  23.   ActiveDD,                   { Active Display Device. }
  24.   AltDD:       byte;          { Alternate Display Device. }
  25.   PCCAltDD:    integer;       { Alt Display for PC Convertible. }
  26.  
  27. const
  28.   NoDisplay = $00;   VgaMono   = $07;
  29.   MdaMono   = $01;   VgaColor  = $08;
  30.   CgaColor  = $02;   DCC9      = $09;
  31.   DCC3      = $03;   DCC10     = $0A;
  32.   EgaColor  = $04;   McgaMono  = $0B;
  33.   EgaMono   = $05;   McgaColor = $0C;
  34.   PgcColor  = $06;   Unknown   = $FF;
  35.  
  36. { Qinit - initializes Q global variables                    ver 3.0, 08-31-87 }
  37. procedure Qinit;
  38. begin
  39. Inline(                  {Assembly by Inline 08/29/87 13:24}
  40.                          {; -- Get computer model and submodel numbers --}
  41.   $B4/$C0/               {        mov   ah,$C0           ; Set AH=$C0}
  42.   $CD/$15/               {        int   $15              ; Do interrupt 15h}
  43.   $72/$06/               {        jc    NoSupp           ; Not supported}
  44.   $26/                   {        es:                    ; Segment override}
  45.   $8B/$57/$02/           {        mov   dx,[bx+$02]      ; Get model and sub}
  46.   $EB/$0C/               {        jmp   SHORT Modes      ; Go check modes}
  47.                          {                               ;}
  48.   $B9/$00/$F0/           {NoSupp: mov   cx,$F000         ; Seg for system ID}
  49.   $8E/$C1/               {        mov   es,cx            ; Set segment}
  50.   $26/                   {        es:                    ; Extra seg override}
  51.   $8A/$16/$FE/$FF/       {        mov   dl,[$FFFE]       ; DL= system ID}
  52.   $88/$CE/               {        mov   dh,cl            ; Set submodel=0}
  53.                          {                               ;}
  54.                          {; -- Check for original systems --}
  55.                          {;    AX= Video segment   (AL= 0)}
  56.                          {;    BH= Video mode       BL= Active display device}
  57.                          {;    CH= MaxPage          CL= CardWait}
  58.                          {;    DH= SubModelID       DL= SystemID}
  59.                          {                               ;}
  60.   $31/$C9/               {Modes:  xor   cx,cx            ; Set CX=0}
  61.   $8E/$C1/               {        mov   es,cx            ; Set ES=0}
  62.   $26/                   {        es:                    ; Extra seg override}
  63.   $8A/$3E/$49/$04/       {        mov   bh,by[$0449]     ; Get video mode}
  64.   $B3/$01/               {        mov   bl,$01           ; ActiveDD=MdaMono}
  65.   $80/$FF/$07/           {        cmp   bh,$07           ; Mode=Monochrome?}
  66.   $75/$05/               {        jne   Color            ;  no, assume color}
  67.                          {                               ;}
  68.   $B8/$00/$B0/           {        mov   ax,$B000         ; Set AX=$B000}
  69.   $EB/$12/               {        jmp   SHORT SetQ       ;}
  70.                          {                               ;}
  71.   $B8/$00/$B8/           {Color:  mov   ax,$B800         ; Set AX=$B800}
  72.   $43/                   {        inc   bx               ; ActDD=CgaColor}
  73.   $B5/$07/               {        mov   ch,$07           ; Set MaxPage=7}
  74.   $38/$DF/               {        cmp   bh,bl            ; Mode= 0 or 1?}
  75.   $78/$08/               {        js    SetQ             ;  yes, 40 col mode}
  76.   $D0/$ED/               {        shr   ch,1             ;  no, MaxPage=3}
  77.   $80/$FA/$FD/           {        cmp   dl,$FD           ; PC Jr?}
  78.   $74/$01/               {        je    SetQ             ;  yes,CardWait=false}
  79.   $41/                   {        inc   cx               ;  no, CardWait=true}
  80.                          {                               ;}
  81.   $A3/>PAGE0SEG/         {SetQ:   mov   [>Page0Seg],ax   ; Set Page0Seg}
  82.   $88/$0E/>CARDWAIT/     {        mov   [>CardWait],cl   ; Set CardWait}
  83.   $88/$2E/>MAXPAGE/      {        mov   [>MaxPage],ch    ; Set MaxPage}
  84.   $A2/>HAVEPS2/          {        mov   [>HavePS2],al    ; Set HavePS2=false}
  85.   $88/$16/>SYSTEMID/     {        mov   [>SystemID],dl   ; Save system ID}
  86.   $88/$36/>SUBMODELID/   {        mov   [>SubModelID],dh ; Save SubModel ID}
  87.   $88/$1E/>ACTIVEDD/     {        mov   [>ActiveDD],bl   ; Set ActiveDispDev}
  88.   $A2/>ALTDD/            {        mov   [>AltDD],al      ; Set AltDispDev=0}
  89.                          {                               ;}
  90.                          {; -- Check for PC convertible LCD (5140) modes --}
  91.   $80/$FA/$F9/           {        cmp   dl,$F9           ; PC convertible?}
  92.   $75/$19/               {        jne   ChkDCC           ;  no}
  93.   $B4/$15/               {        mov   ah,$15           ; Video types}
  94.   $CD/$10/               {        int   $10              ; Call video BIOS}
  95.   $A3/>PCCALTDD/         {        mov   [>PCCAltDD],ax   ; Alt disp model#}
  96.   $26/                   {        es:                    ; Extra seg override}
  97.   $81/$3D/$40/$51/       {        cmp   wo[di],$5140     ; 5140h (LCD)?}
  98.   $75/$7B/               {        jne   SetQ4            ;  no}
  99.   $80/$3E/>ACTIVEDD/$01/ {        cmp   by[>ActiveDD],$01; Emulate MdaMono?}
  100.   $75/$6F/               {        jne   SetQ3            ;  no}
  101.   $B0/$03/               {        mov   al,$03           ; Set MaxPage=3}
  102.   $EB/$68/               {        jmp   SHORT SetQ2      ;}
  103.                          {                               ;}
  104.                          {; -- Check for newer systems --}
  105.   $B8/$00/$1A/           {ChkDCC: mov   ax,$1A00         ; DispCombinationCode}
  106.   $CD/$10/               {        int   $10              ; Call video BIOS}
  107.   $3C/$1A/               {        cmp   al,$1A           ; DCC supported?}
  108.   $75/$1D/               {        jne   ChkEGA           ;  no, check for EGA}
  109.   $C6/$06/>HAVEPS2/$01/  {        mov   by[>HavePS2],$01 ; Set HavePS2=true}
  110.   $88/$1E/>ACTIVEDD/     {        mov   [>ActiveDD],bl   ; Save ActiveDispDev}
  111.   $88/$3E/>ALTDD/        {        mov   [>AltDD],bh      ; Save AltDispDevice}
  112.   $80/$FB/$07/           {        cmp   bl,$07           ; PS/2 active?}
  113.   $78/$0B/               {        js    ChkEGA           ;  no}
  114.   $B8/$00/$12/           {        mov   ax,$1200         ; Cursor emulate on}
  115.   $B3/$34/               {        mov   bl,$34           ; Cursor emulation}
  116.   $CD/$10/               {        int   $10              ; Call video BIOS}
  117.   $B0/$07/               {        mov   al,$07           ; Set MaxPage=7}
  118.   $EB/$42/               {        jmp   SHORT SetQ2      ;}
  119.                          {                               ;}
  120.   $B4/$12/               {ChkEGA: mov   ah,$12           ; Set AH for alt sel}
  121.   $B3/$10/               {        mov   bl,$10           ; Set BL for EGA info}
  122.   $CD/$10/               {        int   $10              ; Call video BIOS}
  123.   $80/$FB/$10/           {        cmp   bl,$10           ; BL changed?}
  124.   $74/$3F/               {        jz    SetQ4            ;  no, no EGA either}
  125.   $88/$0E/>EGASWITCHES/  {        mov   [>EgaSwitches],cl; Save EGA hardware}
  126.   $31/$D2/               {        xor   dx,dx            ; Set dx=0}
  127.   $8E/$C2/               {        mov   es,dx            ; Set es=0}
  128.   $38/$16/>HAVEPS2/      {        cmp   by[>HavePS2],dl  ; DDs not known?}
  129.   $75/$19/               {        jne   Pages            ;  no, calc pages}
  130.   $88/$F8/               {        mov   al,bh            ; Copy EGA CC}
  131.   $04/$04/               {        add   al,$04           ; Make into DCC}
  132.   $26/                   {        es:                    ; Segment override}
  133.   $F6/$06/$87/$04/$08/   {        test  by[$0487],$08    ; EGA active?}
  134.   $74/$05/               {        jz    ActEGA           ;  yes}
  135.   $A2/>ALTDD/            {        mov   [>AltDD],al      ;  no, save as AltDD}
  136.   $EB/$20/               {        jmp   SHORT SetQ4      ; Done}
  137.                          {                               ;}
  138.   $A2/>ACTIVEDD/         {ActEGA: mov   [>ActiveDD],al   ; Save it}
  139.   $2C/$03/               {        sub   al,$03           ; Make AltDD}
  140.   $A2/>ALTDD/            {        mov   [>AltDD],al      ; Save it}
  141.   $B0/$07/               {Pages:  mov   al,$07           ; Set MaxPage=7}
  142.   $84/$DB/               {        test  bl,bl            ; >64kb installed?}
  143.   $75/$0A/               {        jnz   SetQ2            ;  yes, MaxPage=7}
  144.   $26/                   {        es:                    ; Segment override}
  145.   $80/$3E/$49/$04/$02/   {        cmp   by[$0449],$02    ; 40 cols modes?}
  146.   $78/$02/               {        js    SetQ2            ;  yes, MaxPage=7}
  147.   $D0/$E8/               {        shr   al,1             ;  no, set MaxPage=3}
  148.                          {                               ;}
  149.                          {; -- Set Qwik global variables --}
  150.   $A2/>MAXPAGE/          {SetQ2:  mov   [>MaxPage],al    ; Set MaxPage}
  151.   $C6/$06/>CARDWAIT/$00/ {SetQ3:  mov   by[>CardWait],$00; Set CardWait=false}
  152.   $A0/>CARDWAIT/         {SetQ4:  mov   al,[>CardWait]   ; Copy CardWait ...}
  153.   $A2/>QWAIT/            {        mov   [>Qwait],al      ;  to Qwait}
  154.   $A1/>PAGE0SEG/         {        mov   ax,[>Page0seg]   ; Copy Page0seg ...}
  155.   $A3/>QSEG);            {        mov   [>Qseg],ax       ;  to Qseg}
  156. end;
  157.